cmake_minimum_required(VERSION 3.16)
project("tflitebuilder")

#[[ 
if(!TFLITEBUILDER_DIR)
	set(abseil-cpp_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/abseil-cpp CACHE PATH "")
	set(cpuinfo_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/cpuinfo CACHE PATH "")
	set(EGL-Registry_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/EGL-Registry CACHE PATH "")
	set(egl_headers_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/EGL-Registry CACHE PATH "")
	set(eigen_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/eigen CACHE PATH "")
	set(farmhash_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/farmhash CACHE PATH "")
	set(OouraFFT_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/OouraFFT CACHE PATH "")
	set(fft2d_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/OouraFFT CACHE PATH "")
	set(googletest_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/googletest CACHE PATH "")
	set(benchmark_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/benchmark CACHE PATH "")
	set(google_benchmark_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/benchmark CACHE PATH "")
	set(nsync_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/nsync CACHE PATH "")
	set(re2_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/re2 CACHE PATH "")
	set(flatbuffers_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/flatbuffers CACHE PATH "")
	set(FP16_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/FP16 CACHE PATH "")
	set(fp16_headers_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/FP16 CACHE PATH "")
	set(gemmlowp_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/gemmlowp CACHE PATH "")
	set(ARM_NEON_2_x86_SSE_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/ARM_NEON_2_x86_SSE CACHE PATH "")
	set(neon2sse_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/ARM_NEON_2_x86_SSE CACHE PATH "")
	set(OpenCL-Headers_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/OpenCL-Headers CACHE PATH "")
	set(opencl_headers_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/OpenCL-Headers CACHE PATH "")
	set(OpenGL-Registry_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/OpenGL-Registry CACHE PATH "")
	set(opengl_headers_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/OpenGL-Registry CACHE PATH "")
	set(Vulkan-Headers_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/Vulkan-Headers CACHE PATH "")
	set(vulkan_headers_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/Vulkan-Headers CACHE PATH "")
	set(XNNPACK_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/XNNPACK CACHE PATH "")
	set(xnnpack_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/XNNPACK CACHE PATH "")
	set(ruy_SOURCE_DIR ${TFLITEBUILDER_DIR}/deps-base/ruy CACHE PATH "")
endif() ]]


option(TFLITEBUILDER_DIR "tflitebuilder的路径" ${CMAKE_CURRENT_LIST_DIR})

set(TENSORFLOW_SOURCE_DIR "" CACHE PATH
  "Directory that contains the TensorFlow project"
)
if(NOT TENSORFLOW_SOURCE_DIR)
	if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../tensorflow/lite)
		set(TENSORFLOW_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../)
	else()
		message(FATAL_ERROR "请将tflitebuilder放置于tensorflow仓库根目录下")
	endif()
endif()

message(INFO " TFLITEBUILDER_DIR: ${TFLITEBUILDER_DIR}")
message(INFO " TENSORFLOW_SOURCE_DIR: ${TENSORFLOW_SOURCE_DIR}")

include_directories(${TENSORFLOW_SOURCE_DIR})

add_subdirectory(
  "${TENSORFLOW_SOURCE_DIR}/tensorflow/lite"
  "${CMAKE_CURRENT_BINARY_DIR}/tensorflow-lite"
)